# !/usr/bin/python3
# ******************************************************************************
# Copyright (c) Huawei Technologies Co., Ltd. 2021-2021. All rights reserved.
# licensed under the Mulan PSL v2.
# You can use this software according to the terms and conditions of the Mulan PSL v2.
# You may obtain a copy of Mulan PSL v2 at:
#     http://license.coscl.org.cn/MulanPSL2
# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
# PURPOSE.
# See the Mulan PSL v2 for more details.
# ******************************************************************************/
import koji

session = koji.ClientSession("https://koji.fedoraproject.org/kojihub")
try:
    result = session.queryHistory(tables=["build_target_config"], build_target="f36")
    print(f'result is: {result}')
except koji.GenericError as e:
    print(f"error {e}")

# queryHistory(tables=None, **kwargs)
#   Returns history xml_data.json from various tables that support it
#
#     tables: list of versioned tables to search, no value implies all tables
#             valid entries: user_perms, user_groups, tag_inheritance, tag_config,
#                 build_target_config, external_repo_config, tag_external_repos,
#                 tag_listing, tag_packages, tag_package_owners, group_config,
#                 group_req_listing, group_package_listing
#
#     - Time options -
#     times are specified as an integer event or a string timestamp
#     time options are valid for all record types
#     before: either created or revoked before timestamp
#     after: either created or revoked after timestamp
#     beforeEvent: either created or revoked before event id
#     afterEvent: either created or revoked after event id
#
#     - other versioning options-
#     active: select by active status
#     editor: record created or revoked by user
#
#     - table-specific search options -
#     use of these options will implicitly limit the search to applicable tables
#     package: only for given package
#     build: only for given build
#     tag: only for given tag
#     user: only affecting a given user
#     permission: only relating to a given permission
#     external_repo: only relateing to an external repo
#     build_target: only relating to a build target
#     group: only relating to a (comps) group
#     cg: only relating to a content generator